package org.sean.framework.web.endpoint;

import org.sean.framework.context.ApplicationInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
import org.springframework.boot.actuate.endpoint.annotation.WriteOperation;
import org.springframework.context.annotation.Configuration;

/**
 * statusInfo Endpoint
 *
 * @author xielei
 */
@Configuration
@Endpoint(id = "statusInfo")
public class StatusInfoEndpoint {

    @Autowired
    ApplicationInfo applicationInfo;

    @ReadOperation
    public ApplicationInfo getApplicationInfo() {
        return applicationInfo;
    }

    @WriteOperation
    public ApplicationInfo setApplicationInfo(String statusExceptionTrace) {
        applicationInfo.setStatusExceptionTrace(Boolean.parseBoolean(statusExceptionTrace));
        return applicationInfo;
    }
}
